﻿<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<%@page import="system.LoginContext"%>
<%@page import="framework.core.SrvContext"%>
<html>
<head>
<title>申购单信息更改</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language=javascript src="<%=root%>/framework/js/datePicker/WdatePicker.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>
<%
ArrayList wareList = (ArrayList)request.getAttribute("orderdept");
GSOrderModifyQueryVO oaqVO = (GSOrderModifyQueryVO)session.getAttribute("MODIFYQUERYCONDITION");
ResultProcess tOrder = (ResultProcess)request.getAttribute("orderlist");
ArrayList tList = new ArrayList();
String [] tStr = null;
%>
<script>
	<%
		//在此作出成功提示
		if(request.getAttribute("SUCCESSMSG") != null)
			out.print("alert('"+request.getAttribute("SUCCESSMSG")+"');");
	%>
	
	function process(val){

		if(val == 'Q'){
			ordermodifyform.action = "<%=response.encodeURL(root+"/A100502.do")%>";
    		ordermodifyform.submit();	
		}else if(val == 'T'){
			var indexs = document.getElementsByName("indexs");
			var isSelected = false;			
			for(i=0;i<indexs.length;i++){
				if(indexs[i].checked ){
					isSelected = true;
				}
				var deliverdate = document.getElementById("deliverDate"+i).value;
				if(deliverdate==null || deliverdate=="") {
					alert("送货日期不可为空");
					return false;
				}
			}
			if(isSelected != true) {
				alert("请点击复选框以选定申购单明细");
				return false;
			}
			if(confirm("是否确定修改？")){						
				document.pager.action = "<%=response.encodeURL(root+"/A100504.do")%>";
                document.pager.method="post";
				document.pager.submit();
			}else{
				return false;
			}

		}else if(val=='C'){
			ordermodifyform.orderId.value ="";
			ordermodifyform.orderDept.selectedIndex=0;		
			ordermodifyform.concentricityId.value = "";
			ordermodifyform.manufInfo.value = "";
			ordermodifyform.orderCreateDateStr.value = "";
			ordermodifyform.orderCreateDateEnd.value = "";
			ordermodifyform.detailStatus.value = "";
            ordermodifyform.drawingpiececode.value = "";
			return false;					
		}
	}
	
		
	function goview(url){
		window.open(url,null," edge: sunken ; center: Yes; help: No; resizable: Yes; status: No; width: 960px ; height: 800px ; scrollbars:yes");
	}
	function checkManufacture(rownum)
	{
		var rownumary = tokenize(rownum,',');
		var concentricityid = document.getElementById("concentricityid"+rownum).value;
		if(concentricityid == "" || concentricityid == null)
			return false;
		document.all('iframe1').src="<%=response.encodeURL(root+"/jsp/iframe/checkManufacture_yy.jsp")%>?rownum="+rownum+"&concentricityid="+concentricityid;
		return false;
	}
	
	function selectManufacture(index){
		document.getElementById('currentrownum').value = index;
		var url="<%=response.encodeURL(root+"/A100599.do")%>";
		var returnv = window.open(url,null,"height=680px, width=960px, center=Yes, help=No, resizable=Yes, status=No, scrollbars=yes");		
	}
	function modconcentricityid(index){
		if  (event.keyCode==13){  
			modManufacture(index);
			keydown2("orderCount"+index);
		}
	}
	function modManufacture(rownum){
		var concentricityid = document.getElementById("concentricityid"+rownum).value;
		var oldConcentricityid = document.getElementById("concentricityid_"+rownum).value;
		if(concentricityid == "" || concentricityid == null)
			return false;
		if(concentricityid == oldConcentricityid)
			return false; 	
		document.all('iframe1').src="<%=response.encodeURL(root+"/jsp/iframe/OrderModifyManufacture.jsp")%>?isModify=true&oldconcentricityid="+oldConcentricityid+"&rownum="+rownum+"&concentricityid="+concentricityid;
		return false;
	}	
	function keydown2(id){
        if(event.keyCode==13) {
            var obj = document.getElementById(id);
            if (obj.type =="radio")
            {
                obj.checked = true;
            }           
            obj.focus();
        }
    }
</script>
</head>
<iframe id='iframe1' name="iframe1"  width="0" height="0" frameborder = "0" style="display: none;"></iframe>
<body BGCOLOR="#f2f2f2"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">申购单信息修正</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>

<br>
<form name="ordermodifyform" method="get" >
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
					<TD class="bg_column" align=center>申购单编号</TD>
					<TD align=left class="bg_row_odd">
					<input type="text" name="orderId" maxlength="20" value="<%=oaqVO==null?"":oaqVO.orderId%>">
					</TD>					
					<TD class="bg_column" align=center>申购单明细状态</TD>
					<TD align=left class="bg_row_odd">
					<select name='detailStatus'>
						<option value=''>---全部---</option>
						<option value='1' <%if("1".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>已申请</option>
						<option value='2' <%if("2".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>初审通过</option>
						<option value='3' <%if("3".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>复审通过</option>
						<option value='4' <%if("4".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>初审未通过</option>
						<option value='5' <%if("5".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>复审未通过</option>
						<option value='6' <%if("6".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>已提交</option>
						<option value='8' <%if("8".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>未核准</option>
						<option value='11' <%if("11".equals(oaqVO==null?"":oaqVO.detailStatus)) out.print("selected");%>>已拒绝</option>
					</select>
					</TD>					
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>订货单位</TD>
					<TD left=left class="bg_row_odd">
				        <select id='orderDept' name='orderDept'>
							<option value="<%=LoginContext.get(new SrvContext(request,response)).getLoginWarehouseCode() %>">---全部---</option>
                    		<%
                            String tOrderDept = request.getParameter("orderDept")==null?"":request.getParameter("orderDept");
                            if(wareList != null && wareList.size() > 0 ){
                                    for(int i=0; i<wareList.size(); i++){
                                        GSWareHouseBean tmp=(GSWareHouseBean)wareList.get(i);
                                        if(tmp != null && tOrderDept.equals(tmp.getCode())){
                            %>
                                            <option value="<%=tmp.getCode()%>" selected>
                                            <%=tmp.getName()%></option>
                            <%                  
                                        }else{
                            %>
                                            <option value="<%=tmp.getCode()%>"><%=tmp.getName()%></option>
                            <%          
                                        }
                                    }
                                }
                        %>
                       	</select>
					</TD>
                    <td class="bg_column" align=center>图件号</td>
                    <td align=left class="bg_row_odd" >
                    <input type="text" name="drawingpiececode" value="<%=request.getParameter("drawingpiececode")==null? "":request.getParameter("drawingpiececode") %>">
                    </td> 						
				</TR>
				<TR height=20>
					<TD class="bg_column" align=center>集中编码</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="concentricityId" maxlength="20" value="<%=oaqVO==null?"":oaqVO.concentricityId%>">
					</TD>
				</TR>									
				<TR height=20>
					<TD class="bg_column" align=center>产品信息</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="manufInfo" maxlength="200" value="<%=oaqVO==null?"":oaqVO.manufInfo %>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT>）&nbsp;
					</TD>
				</TR>
                <%
                SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                Date d = new Date();
                String strNow = String.valueOf(bartDateFormat.format(d));
                long l=(long)259200*(long)10000;
                Date d2 = new Date(System.currentTimeMillis()-l);
                String strMothAgo = String.valueOf(bartDateFormat.format(d2));
                
                %>  									
				<TR height=20>	
					<TD class="bg_column" align=center>创建时间</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<%=framework.custom.UIManager.generateDateInput("orderCreateDateStr",
							oaqVO==null?strMothAgo:oaqVO.beginDate)%>
						至
					<%=framework.custom.UIManager.generateDateInput("orderCreateDateEnd",
							oaqVO==null?strNow:oaqVO.endDate)%>		
					
					</TD>
				</TR>	
			</table>
		</td>
	</tr>
</table>
<%if(tOrder != null){
    int totalRecords = 0;
    if(request.getAttribute("totalRecords")!=null){
        totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
    }
    int defaultPageSize =10;
    if(request.getAttribute("pageSize")!=null){
        defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
    }
            %>          
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'></page:pager>
            <%} %>
</form>
    <p align="center">  
		<input type="button" class="kuang" value="查询" onclick="process('Q')"/>&nbsp;
		<input type="button" class="kuang" value="清空" onClick="process('C')">
    </p>
<%
	
	if(tOrder != null){
%>
	<center>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name='pager' method="post">
            <input type="hidden" name="currentrownum">
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20> 
                    	<td></td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单编号</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单明细编号</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">明细状态</div>
						</td>									
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">集中编码</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品名称</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">规格</div>
						</td>									
						<td class=top align=middle> 
                        <div align="center" class="txt_content">型号</div>
						</td>									
						<td class=top align=middle> 
                        <div align="center" class="txt_content">品牌</div>
						</td>									
						<td class=top align=middle> 
                        <div align="center" class="txt_content">质保期</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">图件号</div>
                        </td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">供应商</div>
						</td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">价格（元）</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">订货数量</div>
						</td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">订货单位</div>
						</td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">送货日期</div>
						</td>									
						<td class=top align=middle> 
                        <div align="center" class="txt_content">送货时间</div>
						</td>	
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">结算模式</div>
                        </td>								
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">详细</div>
						</td>																																				
					</tr>
					<%
						tList = tOrder.getAllRecoreds();
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
//							String[] tStr = (String[])tList.get(i);
							GSOrderAnaDetailBean tGSOrderVO = (GSOrderAnaDetailBean)tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}

					%>
						
							<tr <%=tTempStr%> height=20>
								<td class=top align=middle > 
									<div align="center" class="txt_content">
									<input type="checkbox" name="indexs" value="<%=tGSOrderVO.getGs_order_detail_id()%>">
									
									</div>
								</td>			
								<td class=top align=middle  > 								
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getGs_order_tempid_order()%>
									</div>
								</td>	
								<td class=top align=middle  > 								
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getGs_order_detail_id()%>
									<input type="hidden" name="orderdetailid" value="<%=tGSOrderVO.getGs_order_detail_id()%>">
									<input type="hidden" name="orderid" value="<%=tGSOrderVO.getGs_order_tempid_order()%>">
									</div>
								</td>	
								<td class=top align=middle > 
									<div align="center" class="txt_content">
									<%=GSBaseManager.getOrderDetailStatusName(tGSOrderVO.getGs_order_detail_status())%>
									<input type='hidden' name='orderDetailStatus' id='orderDetailStatus<%=i%>' value="<%=tGSOrderVO.getGs_order_detail_status()%>">
									</div>
								</td>	
								<td class=top align=middle > 								
									<div align="center" class="txt_content">
									<input type='hidden' name='concentricityid_' value='<%=tGSOrderVO.getGs_concentricity_id()%>'>
									<input type='hidden' id='concentricityid_<%=i %>' name='concentricityid_<%=i %>' value='<%=tGSOrderVO.getGs_concentricity_id()%>'>
									<input type='hidden' name='manufactureid' id='manufactureid<%=i %>' value='<%=tGSOrderVO.getApep_code()%>'>
									<input type='text' size='16' id='concentricityid<%=i%>' name='concentricityid' value='<%=tGSOrderVO.getConcentricity_code()%>' onKeyDown='modconcentricityid(<%=i%>);' onblur='modManufacture(<%=i%>);'>
									<input type="button" class="kuang" value="查询" onclick='selectManufacture(<%=i%>);'>
									</div>
								</td>	
								<td class=top align=middle id='manufacturename<%=i%>'> 								
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A100503.do")%>?concentricityId=<%=tGSOrderVO.getConcentricity_code()%>" target=_blank><%=tGSOrderVO.getName_product()%></a>
									</div>
								</td>	
								<td class=top align=middle id='manufacturespec<%=i%>'> 								
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getSpec()%>
									</div>
								</td>	
								<td class=top align=middle id='manufacturetype<%=i%>'> 
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getModel()%>
									</div>
								</td>
								<td class=top align=middle id='manufacturebrand<%=i%>'> 
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getProduct_brand()%>
									</div>
								</td>
								<td class=top align=middle id='period<%=i%>'> 
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getQuality_assure_period()%>
									</div>
								</td>
                                <td class=top align=middle id='period<%=i%>'> 
                                    <div align="center" class="txt_content">
                                    <%=tGSOrderVO.getDrawing_piece_code()%>
                                    </div>
                                </td>
								<td class=top align=middle id='providerid<%=i%>'> 
									<div align="center" class="txt_content">
										<a href="<%=response.encodeURL(root+"/A150504.do")%>?providerId=<%=tGSOrderVO.getCode()%>" target="_blank"><%=tGSOrderVO.getName()%></a>										
									</div>
								</td>
								<td class=top align=middle id='manufactureunitprice<%=i%>'> 
									<div align="center" class="txt_content">
									<%=StringUtils.formatEDouble(tGSOrderVO.getGs_goods_unitprice(),4)%>
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<input type='text' size='8' id="orderCount<%=i%>" name='ordercount' value='<%=StringUtils.formatEDouble(tGSOrderVO.getGs_order_count(),2)%>' onblur='formatordercount(this)'><div id="quantUnit<%=i%>"><%=tGSOrderVO.getProduct_unit()%></div>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tGSOrderVO.getName_warehouse()%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<input type='text' size="10" id="deliverDate<%=i%>" name='deliverdate' value='<%=tGSOrderVO.getGs_deliver_goods_date()%>' readonly onfocus='setday(this)'>
									</div>
								</td>															
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<select id='delivertime2' name='delivertime'>
	                            		<option value='1' <%if("1".equals(tGSOrderVO.getGs_deliver_goods_time())) out.print("selected");%>>8:00-12:00</option>
	                            		<option value='2' <%if("2".equals(tGSOrderVO.getGs_deliver_goods_time())) out.print("selected");%>>13:00-18:00</option>
	                            		<option value='3' <%if("3".equals(tGSOrderVO.getGs_deliver_goods_time())) out.print("selected");%>>全天</option>
	                            	</select>
									</div>
								</td>
                                <td class=top align=middle>
                                    <div align="center" class="txt_content" id="divmode<%=i %>">
                                    <%=DefineDic.getBalanceMode(tGSOrderVO.getGs_balance_mode())%>
                                    </div>
                                    <input type='hidden' id="mode<%=i%>" name='mode' value='<%=tGSOrderVO.getGs_balance_mode()%>'>
                                </td>																
								<td class=top align=middle > 
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A100506.do")%>?orderId=<%=tGSOrderVO.getGs_order_tempid_order()%>&orderDetailId=<%=tGSOrderVO.getGs_order_detail_id()%>" target="_blank">详细</a>
									</div>
								</td>																																								
							</tr> 
							
					<%	
						}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="19" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm="ordermodifyform"/>
						    </td>
                            </tr>
						  
				    <%
						}else{
					%>
                    <tr class="bg_column" height=20>
                            <td width="960" height="16" colspan="19" align="center">
                               <font color="red">没有符合条件的产品订单信息,请重新输入查询条件</font>
                            </td>
                           </tr>
							
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
	<p align="center">  
    	<input type="button" class="kuang" value="保存修改" onclick="process('T')">
    </p>
	
<%		
	}
%>

<script language='javascript'>
	function formatordercount(obj){	   
	   if (!isFloatNum(obj.value))
	   {
	   		if(!isNum(obj.value))
	   		{
	   			alert("请输入正确的数量！");
	   			obj.focus();
	   			return false;
	   		}
	   		//if(isNum(obj.value))
			//{
				

	   		//}
	   }else
	   {
	   		if(obj.value==0)
	   		{
	   			alert("数量必须大于0");
	   			obj.focus();
	   			return false;
	   		}
	   		obj.value = FormatNum2(obj);
	   }
	}
</script>
</body>
</html>